def method(nums: list):
    A = min(nums) == nums[0] or max(nums) == nums[-1]
    return 'YES' if A else 'NO'

if __name__ == '__main__':
    n = int(input())
    for i in range(n):
        _ = int(input())
        nums = [int(x) for x in input().split(' ')]
        result = method(nums)
        print(result)
    